﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 宏定义的按键的意义
/// </summary>
public enum DefineInputKeyMeans
{
    LEFT,
    RIGHT,
    UP,
    DOWN,
    ENTER,
    ESC,
    ATTACK,
    JUMP
}

public class InputManager : BaseManager<InputManager> {

    #region 按键数组

    KeyCode[][] Keys;

    public KeyCode[] Left;

    public KeyCode[] Right;

    public KeyCode[] Up;

    public KeyCode[] Down;

    public KeyCode[] Enter;

    public KeyCode[] Esc;

    public KeyCode[] Attack;

    public KeyCode[] Jump;

    #endregion

    protected override void OnMyEvent(EVENT_TYPE Event_Type, Component Sender, object Param = null)
    {
        
    }

    private void Awake()
    {
        base.Awake();
        Keys = new KeyCode
            [System.Enum.GetNames(typeof(DefineInputKeyMeans)).Length][];
        Keys[0] = Left;
        Keys[1] = Right;
        Keys[2] = Up;
        Keys[3] = Down;
        Keys[4] = Enter;
        Keys[5] = Esc;
        Keys[6] = Attack;
        Keys[7] = Jump;
    }

    public bool GetTheKeyDown(DefineInputKeyMeans mean)
    {
        foreach(KeyCode k in Keys[(int)mean])
        {
            if(Input.GetKeyDown(k))
            {
                return true;
            }
        }
        return false;
    }

    public bool GetTheKeyUp(DefineInputKeyMeans mean)
    {
        foreach (KeyCode k in Keys[(int)mean])
        {
            if (Input.GetKeyUp(k))
            {
                return true;
            }
        }
        return false;
    }

    public bool GetTheKey(DefineInputKeyMeans mean)
    {
        foreach (KeyCode k in Keys[(int)mean])
        {
            if (Input.GetKey(k))
            {
                return true;
            }
        }
        return false;
    }

}
